package cate.game.server.controller.mock;

import cate.game.server.controller.MockController;
import cp.solution.business.sys.account.dto.AccountLoginReq;
import cp.solution.business.sys.account.dto.AccountLoginResp;
import easy.java.practice.web.RawResponse;
import easy.java.spring.annotation.MyGetMapping;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@RequestMapping("mock/login/")
@MockController
public class MockLoginController extends MockControllerBase {

    // http://localhost:5500/mock/login/auto
    // 从登录开始自动运行
    @MyGetMapping(value = "auto")
    @ResponseBody
    @RawResponse
    public String auto() throws Exception{
        new Thread(() -> this.cli.auto()).start();
        return "{\"r\":\"OK\"}";
    }

    // 向 login-server 登录
    @MyGetMapping("login")
    @ResponseBody
    public AccountLoginResp login(AccountLoginReq req) {
        return this.cli.login(req);
    }
}
